/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.com.intesal.clases;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ejerez
 */
public class cVarios {

    private Integer round;

    public cVarios() {
        this.round = 2;
    }

    public cVarios(Integer round) {
        this.round = round;
    }

    public Double AproximarDecimal(double val) {
        BigDecimal big = new BigDecimal(val);
        big = big.setScale(this.round, RoundingMode.HALF_UP);
        return big.doubleValue();
    }

    private BigDecimal Aproximar_Decimal(double val) {
        BigDecimal big = new BigDecimal(val);
        big = big.setScale(2, RoundingMode.HALF_UP);
        return big;
    }

    private BigDecimal Aproximar_Double(double val) {
        BigDecimal big = new BigDecimal(val);
        big = big.setScale(2, RoundingMode.HALF_UP);
        return big;
    }

    public List TipoPago() {
        try {
            List list = new ArrayList();
            list.add("CCF");
            list.add("CF");
            return list;
        } catch (Exception e) {
            return null;
        }
    }

    public List FormaPago() {
        try {
            List list = new ArrayList();
            list.add("Contado");
            list.add("Credito");
            return list;
        } catch (Exception e) {
            return null;
        }
    }

    public static Date getFecha(java.util.Date date) throws Exception {
        try {
            return new java.sql.Date(date.getTime());
        } catch (Exception e) {
            throw new Exception(e);
        }
    }

    public static Date getFecha_PS_1(java.util.Date date) throws Exception {
        try {
            return new java.sql.Date(new java.util.Date(date.toString()).getTime());
        } catch (Exception e) {
            throw new Exception(e);
        }
    }
}
